package com.ghsc.ghxc.jsb.ui.my.activity

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.ui.my.bean.FollowFansResult
import com.ghsc.ghxc.jsb.ui.my.bean.LikeCollFollowResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.my.activity
 * 类名：FollowFansListViewModel
 * 创建时间：2024/5/17 15:27
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class FollowFansListViewModel : BaseViewModel() {
    /**
     * 我的关注列表
     */
    var onMyFollowListData = MutableLiveData<BaseResponse<FollowFansResult>>()
    fun onMyFollowListMethod(paras: String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onMyFollowListData(paras) }
            executeResponse(
                response,
                { onMyFollowListData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }
    }

    /**
     * 我的粉丝列表
     */
    var onMyFansListData = MutableLiveData<BaseResponse<FollowFansResult>>()
    fun onMyFansListMethod(paras: String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onMyFansListData(paras) }
            executeResponse(
                response,
                { onMyFansListData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }
    }
    /** 关注用户 **/
    val onUserFollowData: MutableLiveData<BaseResponse<LikeCollFollowResult>> = MutableLiveData()
    fun onUserFollowMethod(paras:String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onUserFollowData(paras) }
            executeResponse(
                response,
                { onUserFollowData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }
    }
}